package com.tupu.controller.dispatch;

import com.tupu.common.Result;
import com.tupu.service.dispatch.IOcsDataSyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/api/datasync")
@RestController
public class OcsDataSyncController {

    @Autowired
    private IOcsDataSyncService ocsDataSyncService;

    @RequestMapping("/syncDay")
    public Result syncDay() {
        try {
            ocsDataSyncService.syncBay();
            return Result.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error(e.getMessage());
        }
    }

    @RequestMapping("/syncDevice")
    public Result syncDevice() {
        try {
            ocsDataSyncService.syncDevice();
            return Result.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error(e.getMessage());
        }
    }

    @RequestMapping("/syncDevLine")
    public Result syncDevLine() {
        try {
            ocsDataSyncService.syncDevLine();
            return Result.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error(e.getMessage());
        }
    }

    @RequestMapping("/syncStation")
    public Result syncStation() {
        try {
            ocsDataSyncService.syncStation();
            return Result.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error(e.getMessage());
        }
    }
}
